$().ready(function(){
	
	$baseUrl=$("#baseUrl").text();
	
$(".deleteLink").click(function(){

	if (!confirm("真的要删除本次邀请?"))
	return false;
});

$("#post").click(function(e){
	
	$comment = $('#comment').val();
	$invited_user_id = $('#invited_user_id').val();
	$invitation_id = $('#invitation_id').val();
	
	if ($comment.length<6) {
		alert("表灌水！-_-|| (五个字以上)");
		return false;
	}
	
	$('#comment').addClass("processing");
    $.post($baseUrl+'/invitation/viewmessageajax',
				{'invited_user_id':$invited_user_id, 'comment':$comment, 'invitation_id':$invitation_id},
				function(data){
					$('#commentArea ul').remove();
					$('#commentArea').append(data);
					$('#comment').removeClass("processing").val('');
				});
    return false;
	
});


$("#yes,#no,#maybe").live('click',function(e){
	
	$this = $(this);
	
	$invited_user_id = $('#invited_user_id').val();
	$invitation_id = $('#invitation_id').val();
	$r = $this.attr('id');
	$response=1;
	if ($r=='no')
		$response = 0;
	if ($r=='maybe')
	    $response = 2;	
	
	$this.addClass("processing");
	
    $.post($baseUrl+'/invitation/viewattendajax',
				{'invited_user_id':$invited_user_id, 'response':$response, 'invitation_id':$invitation_id},
				function(data){
					$('#attendArea').remove();
					$('#siteColumn').append(data);
					$this.removeClass("processing");
				});
    
    return false;
	
});

$(".deleteMessage").live('click',function(e){
	
	$this = $(this);
	$invited_user_id = $('#invited_user_id').val();
	$message_id = $this.attr('mid');
	$invitation_id = $('#invitation_id').val();	
	
	$this.parents("li").addClass("processing");
	
    $.post($baseUrl+'/invitation/viewdeletecommentajax',
				{'message_id':$message_id, 'invitation_id':$invitation_id, 'invited_user_id':$invited_user_id},
				function(data){
					$('#commentArea ul').remove();
					$('#commentArea').append(data);
					$('#comment').removeClass("processing").val('');
					
				});
    
    return false;
	
});


});